#!/bin/bash

cat > /tmp/localepurge.preseed << EOF
localepurge localepurge/remove_no note
localepurge localepurge/verbose boolean false
localepurge localepurge/use-dpkg-feature  boolean false
localepurge localepurge/quickndirtycalc boolean false
localepurge localepurge/dontbothernew boolean true
localepurge localepurge/mandelete boolean true
localepurge localepurge/nopurge multiselect en, en_US, en_US.UTF-8
localepurge localepurge/showfreedspace  boolean true
localepurge localepurge/none_selected boolean false
EOF
debconf-set-selections < /tmp/localepurge.preseed
rm -f /tmp/localepurge.preseed
dpkg-reconfigure --frontend=noninteractive localepurge
sed -i "s/^\(USE_DPKG\)/#\1/" /etc/locale.nopurge
sed -i "s/^\(NEEDSCONFIGFIRST\)/#\1/" /etc/locale.nopurge
sed -i "/^en/d" /etc/locale.nopurge
echo "en" >> /etc/locale.nopurge
echo "en_US" >> /etc/locale.nopurge
echo "en_US.UTF-8" >> /etc/locale.nopurge
localepurge

cat > /etc/environment << EOF
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
TERM=linux
PYTHONDONTWRITEBYTECODE=1
EOF

cat > /etc/locale.conf << EOF
LANG=en_US.UTF-8
EOF

sed -e '/en_US.UTF-8/s/^#*[[:space:]]*//g' -i /etc/locale.gen
locale-gen
